load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "metrics",
    srcs = [
        "bindinfo.go",
        "br.go",
        "ddl.go",
        "distsql.go",
        "disttask.go",
        "domain.go",
        "executor.go",
        "gc_worker.go",
        "globalsort.go",
        "import.go",
        "infoschema.go",
        "log_backup.go",
        "meta.go",
        "metrics.go",
        "owner.go",
        "rawkv.go",
        "resource_group.go",
        "resourcemanager.go",
        "server.go",
        "session.go",
        "sli.go",
        "stats.go",
        "telemetry.go",
        "topsql.go",
        "ttl.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/metrics",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/lightning/metric",
        "//pkg/metrics/common",
        "//pkg/parser/terror",
        "//pkg/timer/metrics",
        "//pkg/util/logutil",
        "//pkg/util/promutil",
        "@com_github_pingcap_errors//:errors",
        "@com_github_prometheus_client_golang//prometheus",
        "@com_github_prometheus_client_golang//prometheus/collectors",
        "@com_github_prometheus_client_model//go",
        "@com_github_tikv_client_go_v2//metrics",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "metrics_test",
    timeout = "short",
    srcs = [
        "main_test.go",
        "metrics_internal_test.go",
        "metrics_test.go",
    ],
    embed = [":metrics"],
    flaky = True,
    shard_count = 4,
    deps = [
        "//pkg/parser/terror",
        "//pkg/statistics/handle/cache",
        "//pkg/testkit/testsetup",
        "@com_github_pingcap_errors//:errors",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
